//
//  NSErrorAdditions.m
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "NSErrorAdditions.h"

@implementation NSError (Tint)


#pragma mark - Creating

+ (NSError *)errorWithDescription:(NSString *)description
{
    return [self errorWithDomain:@"com.global" 
                     description:description];
}

+ (NSError *)errorWithDescription:(NSString *)description 
                    failureReason:(NSString *)failureReason
{
    return [self errorWithDomain:@"com.global" 
                     description:description 
                   failureReason:failureReason];
}



+ (NSError *)errorWithDomain:(NSString *)domain 
                 description:(NSString *)description
{
    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
                              description, NSLocalizedDescriptionKey, nil];
	NSError *error = [self errorWithDomain:domain code:0 userInfo:userInfo]; // AUTO
    [userInfo release];
    return error;
}

+ (NSError *)errorWithDomain:(NSString *)domain 
                 description:(NSString *)description 
               failureReason:(NSString *)failureReason
{
    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
                              description, NSLocalizedDescriptionKey, 
                              failureReason, NSLocalizedFailureReasonErrorKey, nil];
    NSError *error = [self errorWithDomain:domain code:0 userInfo:userInfo]; // AUTO
    [userInfo release];
    return error;
}

@end
